class_name MapManager
extends Node2D

#region 属性
@export var map_infos:Array[MapInfo]
@export var room_infos:Array[RoomInfo]
var room_info_dict:Dictionary[String,RoomInfo] = {}
var map_info_dict:Dictionary[String,MapInfo] = {}
var map_generator:MapGenerator
var room_generator:RoomGenerator
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func init():
	for room_info in room_infos:
		if not room_info_dict.has(room_info.room_id):
			room_info_dict.set(room_info.room_id,room_info)
	for map_info in map_infos:
		if not map_info_dict.has(map_info.map_id):
			map_info_dict.set(map_info.map_id,map_info)
	map_generator = MapGenerator.new(self)
	room_generator = RoomGenerator.new(self)
func get_map_info_by_id(map_id:String) -> MapInfo:
	return map_info_dict.get(map_id,null)
func get_room_info_by_id(room_id:String) -> RoomInfo:
	return room_info_dict.get(room_id,null)
func create_map_by_id(map_id:String) -> BaseMap:
	var map_info = get_map_info_by_id(map_id)
	if not map_info:
		return null
	return map_generator.generate_map(map_info)
func create_map_random() -> BaseMap:
	var map_info = map_infos.pick_random()
	return create_map_by_id(map_info.map_id)
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _enter_tree() -> void:
	init()
func _ready() -> void:
	create_map_by_id("10002")
	pass
#endregion
